<template>
  <RecordsBox v-for="item in scoreDetailList" :key="item.id" :type="type" :data="item" />
</template>

<script lang="ts" setup>
import RecordsBox from '../RecordsBox/index.vue'
import { getScoreDetail } from '@/api/home'
import type { IScoreDetail } from '@/api/home/types'
import { useUserStoreWidthOut } from '@/store/modules/user'

interface Props {
  /**
   * 0 获取积分 1 消费积分
   */
  type: '0' | '1'
}

const props = withDefaults(defineProps<Props>(), {
  type: '0',
})

const userStore = useUserStoreWidthOut()
const scoreDetailList = ref<IScoreDetail[]>([])
async function getData() {
  const res = await getScoreDetail({
    phone: userStore.getUserInfo.phone,
    type: props.type,
    sort: 'id,desc',
    page: 1,
    size: 100,
  })
  scoreDetailList.value = res.data.records
}
getData()
</script>

<style lang="less" scoped></style>
